package com.hxgis.common.init;

import com.hxgis.common.base.GroupAnalysisCache;
import com.hxgis.common.base.StationCache;
import com.hxgis.common.base.YearStationCache;
import com.hxgis.common.enums.PreYear30Enum;
import com.hxgis.common.service.RainAnalysisService;
import com.hxgis.common.service.RainstormCourseService;
import com.hxgis.common.service.StationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class InitBaseInfo implements CommandLineRunner  {

    @Autowired
    StationService stationService;

    @Autowired
    private RainstormCourseService rainstormCourseService;

    @Autowired
    private RainAnalysisService rainAnalysisService;

    @Override
    public void run(String... args) throws Exception {
        StationCache.init(stationService.selectAll());
        //这里果断时间要重新跑一下
        GroupAnalysisCache.init(rainstormCourseService.analysisGroup(PreYear30Enum.PRE_YEAR_30_START.getYear() + "0101",
                PreYear30Enum.PRE_YEAR_30_END.getYear() + "1231"));

        YearStationCache.init(null);


        //保存每个站点的阈值，要把基础信息跑完了才能保存
//        ExtremeEventCache.init(rainAnalysisService.getThresholdAnalysis(PreYear30Enum.PRE_YEAR_30_START.getYear() + "0101",
//                PreYear30Enum.PRE_YEAR_30_END.getYear() + "1231"));




    }
}
